package com.zoolu.sip.dialog;

import com.zoolu.sip.dialog.Dialog;
import com.zoolu.sip.message.BaseSipMethods;
import com.zoolu.sip.message.Message;
import com.zoolu.sip.provider.Identifier;
import com.zoolu.sip.provider.MethodIdentifier;
import com.zoolu.sip.provider.SipProvider;
import com.zoolu.sip.provider.SipProviderListener;


public class KickOutDialog extends Dialog {
	
	public SipProviderListener listener;
	public KickOutListener kickOutListener ;
	private Message message = null;
	private boolean flag = false;

	public KickOutDialog(SipProvider provider, KickOutListener kickOutListener) {
		super(provider);
		// TODO Auto-generated constructor stub
		provider.addSipProviderListener(this);
		listener = this;
		this.kickOutListener =kickOutListener;
		Identifier key = new MethodIdentifier(BaseSipMethods.KICKOUT);
		sip_provider.addSipProviderListener(key, this);
	}

	@Override
	protected String getStatusDescription() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected int getStatus() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean isEarly() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isConfirmed() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isTerminated() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onReceivedMessage(SipProvider provider, Message msg) {
		// TODO Auto-generated method stub
		// added by zhh_li 2015-11-30 for kickout
		if(!flag){// 收到多个KICKOUT 只执行一次
			message = msg;
			flag = true;
			kickOutListener.onKickOut(msg);
		}
	}
	
	
	

}
